package com.tencent.common;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
	/**
	 */
	public static String md5(String plainText) {
		byte[] secretBytes = null;
		try {
			secretBytes = MessageDigest.getInstance("md5").digest(
					plainText.getBytes());
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException("找不到md5算法");
		}
		String md5code = new BigInteger(1, secretBytes).toString(16);
		for (int i = 0; i < 32 - md5code.length(); i++) {
			md5code = "0" + md5code;
		}
		return md5code;
	}
	
	public static void main(String[] args) {
		System.out.println(md5("appid=wx6c091aeeff8150e4&body=常州市-上海1天旅游包车&device_info=WEB&mch_id=1487362632&nonce_str=uqfc4ngl563a695ipg5ah19n2tz6t93v&out_trade_no=00000000000000000000000011001817&spbill_create_ip=182.61.34.76&total_fee=135100&key=c8d307d9624c4dd89c69fa3c9d83a5ca"));
	}
}
